package lv.solcraft.replication.server.model;

import net.sf.json.JSONObject;

public class ClientState {

    private long siteId;

    private OperState state;

    private String message = "";

    public long getSiteId() {
        return siteId;
    }

    public void setSiteId(long siteId) {
        this.siteId = siteId;
    }

    public OperState getState() {
        return state;
    }

    public void setState(OperState state) {
        this.state = state;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }


    public static ClientState create(JSONObject json) {
        ClientState state = new ClientState();
        state.setSiteId(json.getLong("siteId"));
        state.setState(OperState.valueOf(json.getString("state")));
        state.setMessage(json.optString("message", ""));
        return state;
    }
}
